import {UnwrapNestedRefs} from "vue";

export interface UserInfo {
  id: number | string
  username: string
  nickname: string
  avatar: string
  roles?: (string | number)[]
}

export interface FormState {
  id: number | string
  username: string
  password: any
  userSex: string
  age: string
  address: string
  nickname: string
  email: string
  phone: string
}

export function getUserInfoApi() {
  return useGet<UserInfo>('/user/info')
}

export function userSaveApi(formState: UnwrapNestedRefs<FormState> & {}) {
  return usePost<number>('/user/save', formState)
}

export function userUpdateApi(formState: UnwrapNestedRefs<FormState> & {}) {
  return usePost<number>('/user/update', formState)
}

export function userDeleteApi(id: number | string) {
  return usePost<string>('/user/delete', { 'id': id })
}
